<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/11/14
 * Time: 14:09
 */

namespace App\Http\Controllers\Home;

use App\Http\Controllers\Controller;
use Auth;
use Illuminate\Support\Facades\View;
use Session;
use Request;
use App\Services\ValidateCode;
use Redirect;
class RegisterController extends Controller
{

    public function index(){
        $url = url('/Home/Index/index');
        return Redirect::to($url);
        return view('home.register.index',[]);
    }

    public function register(){
        $url = url('/Home/Index/index');
        return Redirect::to($url);
        $data = [];
        $data['name'] = trim(Request::input("name"));
        $data['email'] = trim(Request::input("email"));
        $data['password'] = trim(Request::input("password"));
        $data['rpassword'] = trim(Request::input("rpassword"));
        $imgCode = trim(Request::input("img_code"));
        if($imgCode != Session::get('reg_img_code'))
            return $this->showMsg('0','验证码不正确','/Home/Register/index');

        $UserSP = new \App\Factories\UserFactory;

        $res = $UserSP->register($data);
        if(is_array($res)){
            return $this->showMsg('0',$res['msg'],'/Home/Register/index');
        }

        $url = url('/Home/Index/index');
        return Redirect::to($url);
    }

    public function imgCode(){
        $code = new ValidateCode();

        $code->doimg('reg');
    }
}